package com.fetch;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;


public class FetchImage extends AsyncTask<Object,Void,Bitmap> {

	private String url;
	
	public FetchImage(String url) {
	this.url = url;
	}
	


	@Override
	protected Bitmap doInBackground(Object... params) {
		try {
				
	        java.net.URL URL = new java.net.URL(this.url);
	        HttpURLConnection connection = (HttpURLConnection) URL
	                .openConnection();
	        connection.setDoInput(true);
	        connection.connect();
	        InputStream input = connection.getInputStream();
	        Bitmap myBitmap = BitmapFactory.decodeStream(input);
	        return myBitmap;
	    } catch (IOException e) {
	        e.printStackTrace();
	        return null;
	    }
	}
}
